package freedom.easyit.task;

import java.io.FileNotFoundException;

import javax.mail.MessagingException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import freedom.easyit.service.MailService;
import lombok.extern.slf4j.Slf4j;

/**
 * @author Charlie Email:tingfangcao@163.com
 * @date 2020/10/21
 */
@Configuration
@EnableScheduling
@Slf4j
public class ScheduleTask {
    @Autowired
    private MailService mailService;

    // 定义邮件发送任务，每30秒执行一次
    //@Scheduled(fixedRate = 1000 * 10)
    private void configureSendMailTask() throws FileNotFoundException, MessagingException {
        log.info("开始执行邮件发送任务");
        mailService.send();
        log.info("执行邮件发送任务完毕");
    }
}